package com.allprs.hmcs.service.impl;

import com.allprs.common.core.domain.AjaxResult;
import com.allprs.common.utils.StringUtils;
import com.allprs.hmcs.entity.HyParking;
import com.allprs.hmcs.entity.PipeCorridor;
import com.allprs.hmcs.mapper.ParkingLotMapper;
import com.allprs.hmcs.mapper.PipeCorridorMapper;
import com.allprs.hmcs.pojo.reqBo.ParkingLotQueryBo;
import com.allprs.hmcs.pojo.reqBo.PipeCorridorQueryBo;
import com.allprs.hmcs.service.IParkingLotService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author wjf
 * @描述:
 * @date 2024年06月26日
 * @version: 1.0
 */

@Service
public class ParkingLotServiceImpl implements IParkingLotService {

    @Resource
    private ParkingLotMapper parkingLotMapper;

    @Resource
    private PipeCorridorMapper pipeCorridorMapper;


    @Override
    public List<HyParking> getParkingLotList(ParkingLotQueryBo queryBo) {
        QueryWrapper<HyParking> queryWrapper = new QueryWrapper<>();
        queryWrapper.like(StringUtils.isNotBlank(queryBo.getId()), "id", queryBo.getId());

        List<HyParking> hyParkings = parkingLotMapper.selectList(queryWrapper);

        return hyParkings;
    }

    @Override
    public AjaxResult getPipeCorridorInfo(PipeCorridorQueryBo queryBo) {
        QueryWrapper<PipeCorridor> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq(queryBo.getId() != null && queryBo.getId() != 0, "id", queryBo.getId())
                .like(StringUtils.isNotBlank(queryBo.getName()), "name", queryBo.getName());

        List<PipeCorridor> pipeCorridorList = pipeCorridorMapper.selectList(queryWrapper);

        return AjaxResult.success(pipeCorridorList);
    }


}
